package com.fable.sp.core.repository;

import com.fable.sp.core.domain.Layout;
import com.fable.sp.core.service.LayoutQuery;
import com.slyak.spring.jpa.GenericJpaRepository;
import com.slyak.spring.jpa.TemplateQuery;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;

import java.util.List;

/**
 * .
 *
 * @author stormning on 16/7/28.
 */
public interface LayoutRepository extends GenericJpaRepository<Layout, Long> {

    @Override
    @Cacheable(cacheManager = "spCacheManager", value = "l_findOne", key = "#p0")
    Layout findOne(Long id);

    @Override
    @CacheEvict(cacheManager = "spCacheManager", value = "l_findOne", key = "#p0.id")
    <S extends Layout> S save(S entity);

    Layout findByContainerIdAndOriginal(Long containerId, boolean original);

    @TemplateQuery
    List<Layout> listLayouts(LayoutQuery layoutQuery);
}
